﻿using System;
using System.Threading.Tasks;
using System.Windows.Input;
using AvaloniaMvvm.Services;
using CommunityToolkit.Mvvm.Input;

namespace AvaloniaMvvm.ViewModels;

public class MainWindowViewModel : ViewModelBase {
    private readonly IPoetryStorage _poetryStorage;
    
    public MainWindowViewModel() {
        SayHelloCommand = new RelayCommand(SayHello);
        InsertDataCommand = new AsyncRelayCommand(InsertDataAsync);
        ListDataCommand = new AsyncRelayCommand(ListDataAsync);
        QueryDataCommand = new AsyncRelayCommand(QueryDataAsync);
        // TODO
    }

    public string Greeting => "Welcome to Avalonia!";

    private string _message;

    public string Message {
        get => _message;
        set => SetProperty(ref _message, value);
    }

    public ICommand SayHelloCommand { get; }

    public void SayHello() {
        Message = "Hello, Avalonia!";
    }

    public ICommand InsertDataCommand { get; }

    public async Task InsertDataAsync() {
        var name = "Name" + new Random().Next();
        // TODO
    }

    public ICommand ListDataCommand { get; }

    public async Task ListDataAsync() {
        // TODO
    }

    public ICommand QueryDataCommand { get; }

    public async Task QueryDataAsync() {
        // TODO
    }
}